package Fork_Join_in_Java7_chapt_10;

import java.util.concurrent.ForkJoinPool;

/*import jsr166y.forkjoin.ForkJoinExecutor;
import jsr166y.forkjoin.ForkJoinPool;*/

public class Test {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		System.out.println("test performance");
	
		
		
		Problem test=new Problem();
		
		//Check number of available procesors
		int nThreads=Runtime.getRuntime().availableProcessors();
		System.out.println(nThreads);
		
		  Solver mfj = new Solver(test.getList());
		  
		  
		  ForkJoinPool pool = new ForkJoinPool(nThreads);
		    pool.invoke(mfj);
	
		    long result=0;
	//	    long result = mfj.getResult(); // there is no such method , Lars Vogel use some library
		    System.out.println("Done. Result: " + result);
		    long sum = 0;
		    // Check if the result was ok
		    for (int i = 0; i < test.getList().length; i++) {
		      sum += test.getList()[i];
		    }
		    System.out.println("Done. Result: " + sum);
	}

}
